#include "SWARMTask.hpp"

tbb::tick_count tick;

#include <vector>
extern std::vector<int> PARAMS;

#define __TASK_DEF__
#include "AutoGenSupport.hpp"
// template <int TASK_ID, int NPARAMS, int TASKTAGDIM, int INTERTASKDIM> 
// void SWARMTask <TASK_ID, NPARAMS, TASKTAGDIM, INTERTASKDIM>::operator()() {  
RSTREAM_TASK_DEF(0, 7, 3)
#undef  __TASK_DEF__

  PARAMS.insert(PARAMS.begin(), params.begin(), params.end());

  tick = tbb::tick_count::now();

#ifdef MEASURE_OVERHEADS
  GlobalTimers::Singleton().init();
#endif // MEASURE_OVERHEADS

// // TODO: Isolate the sequential overhead measurement  
// #define __TASK_TAG_INIT__
// #include "AutoGenSupport.hpp"
//   // SwarmTaskTag<0, 7, 3> *t = 
//   //   new SwarmTaskTag<0, 7, 3>
//   //   (0, 0, 0, static_cast<tag_elem_t>(params[0]), 
//   //    static_cast<tag_elem_t>(params[1]), static_cast<tag_elem_t>(params[2]), 
//   //    static_cast<tag_elem_t>(params[3]));
//   // SwarmTagWrapper<SwarmTaskTag<0, 7, 3> > stw(t);

// RSTREAM_TASK_TAG_INIT(stw, 0, 7, 3, 
//                       0, 0, 0,
//                       static_cast<tag_elem_t>(params[0]), 
//                       static_cast<tag_elem_t>(params[1]), static_cast<tag_elem_t>(params[2]), 
//                       static_cast<tag_elem_t>(params[3]))
// #undef __TASK_TAG_INIT__

// // TODO: Isolate the sequential overhead measurement  
// #define __START_RUNTIME__
// #include "AutoGenSupport.hpp"
// //swarm_posix_enterRuntime(NULL, &CODELET(startup), &stw, NULL);
// RSTREAM_START_RUNTIME(stw, ID, TOTDIM, ITDIM)
// #undef __START_RUNTIME__


#define __TASK_TAG_INIT_AND_START_RUNTIME__
#include "AutoGenSupport.hpp"
RSTREAM_TASK_TAG_INIT_AND_START_RUNTIME(0, 7, 3,
                                        0, 0, 0,
                                        static_cast<tag_elem_t>(params[0]), 
                                        static_cast<tag_elem_t>(params[1]), 
                                        static_cast<tag_elem_t>(params[2]), 
                                        static_cast<tag_elem_t>(params[3]))
#undef __TASK_TAG_INIT_AND_START_RUNTIME__

  // Termination happens automatically as soon as all tasks are finished
  // through chaining of the shutdown codelet
}
